home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection Student Program / ADC Tools Sampler CD Disk 3 1999.iso / Metrowerks CodeWarrior / Java Support / Java_Source / IFC_112 / netscape / util / Enumeration.java < prev    next >
Encoding:
Text File  |  1999-05-28  |  1.0 KB  |  33 lines  |  [TEXT/CWIE]

  1. // Enumeration.java
  2. // By Ned Etcode
  3. // Copyright 1995, 1996, 1997 Netscape Communications Corp.  All rights reserved.
  4.  
  5. package netscape.util;
  6.  
  7. /** The Enumeration interface specifies an API enabling iteration through a set
  8.   * of elements. The following code demonstrates how to print all the values of
  9.   * a Hashtable using an Enumeration:
  10.   * <pre>
  11.   *     Enumeration enumeration;
  12.   *     Object key;
  13.   *     enumeration = table.keys();
  14.   *     while (enumeration.hasMoreElements()) {
  15.   *         key = enumeration.nextElement();
  16.   *         System.out.println("key = " + key + ", value = " + table.get(key);
  17.   *     }
  18.   * </pre>
  19.   *
  20.   * @see NoSuchElementException
  21.   */
  22. public interface Enumeration {
  23.     /** Returns <b>true</b> if there are additional elements to enumerate.
  24.       */
  25.     boolean hasMoreElements();
  26.  
  27.     /** Returns the next element of the enumeration. This method throws a
  28.       * <b>NoSuchElementException</b> if <b>hasMoreElements()</b> returns
  29.       * <b>false</b>.
  30.       */
  31.     Object nextElement();
  32. }
  33.